API: Add gtk_widget_draw()
authorBenjamin Otte <otte@redhat.com>
Sat, 11 Sep 2010 03:19:28 +0000 (05:19 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:43 +0000 (15:11 +0200)
And here's the final patch that all the previous patches were about.

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkwidget.c
gtk/gtkwidget.h

index 16f3b0288d88f837c8093348c41fe8d0016e60ad..03f2bf75b81e23a4d6800670281fb044f4045bac 100644 (file)
@@ -4768,6 +4768,7 @@ gtk_widget_map
 gtk_widget_unmap
 gtk_widget_realize
 gtk_widget_unrealize
+gtk_widget_draw
 gtk_widget_queue_draw
 gtk_widget_queue_resize
 gtk_widget_queue_resize_no_redraw
index 60053a5e3426c8cbee3bda947800135ac4118652..15b7c857281b3a3021134a2f439ce1502ddd544a 100644 (file)
@@ -4198,6 +4198,7 @@ gtk_widget_create_pango_context
 gtk_widget_create_pango_layout
 gtk_widget_destroy
 gtk_widget_destroyed
+gtk_widget_draw
 gtk_widget_ensure_style
 gtk_widget_error_bell
 gtk_widget_event
index 38d3dea24f62b2ef882337bb0e7bf366d633f569..e397016692d53da5abb55c72b05f6ff62f5c5832 100644 (file)
@@ -5119,6 +5119,53 @@ _gtk_widget_draw_internal (GtkWidget *widget,
     }
 }
 
+/**
+ * gtk_widget_draw:
+ * @widget: the widget to draw. It must be drawable (see 
+ *   gtk_widget_is_drawable()) and a size must have been allocated.
+ * @cr: a cairo context to draw to
+ *
+ * Draws @widget to @cr. The top left corner of the widget will be
+ * drawn to the currently set origin point of @cr.
+ *
+ * You should pass a cairo context as @cr argument that is in an
+ * original state. Otherwise the resulting drawing is undefined. For
+ * example changing the operator using cairo_set_operator() or the
+ * line width using cairo_set_line_width() might have unwanted side
+ * effects.
+ * You may however change the context's transform matrix - like with
+ * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
+ * region with cairo_clip() prior to calling this function. Also, it
+ * is fine to modify the context with cairo_save() and
+ * cairo_push_group() prior to calling this function.
+ *
+ * <note><para>Special purpose widgets may contain special code for
+ * rendering to the screen and might appear differently on screen
+ * and when rendered using gtk_widget_draw().</para></note>
+ **/
+void
+gtk_widget_draw (GtkWidget *widget,
+                 cairo_t   *cr)
+{
+  GdkEventExpose *tmp_event;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (cr != NULL);
+
+  cairo_save (cr);
+  /* We have to reset the event here so that draw functions can call
+   * gtk_widget_draw() on random other widgets and get the desired
+   * effect: Drawing all contents, not just the current window.
+   */
+  tmp_event = _gtk_cairo_get_event (cr);
+  gtk_cairo_set_event (cr, NULL);
+
+  _gtk_widget_draw_internal (widget, cr, TRUE);
+
+  gtk_cairo_set_event (cr, tmp_event);
+  cairo_restore (cr);
+}
+
 static gboolean
 gtk_widget_real_key_press_event (GtkWidget         *widget,
                                 GdkEventKey       *event)
index 5b9e3a5a38da24fd9db8e0ca027842df52126a3d..117cd2e883ec155ffa2fabc714c56ec417137c66 100644 (file)
@@ -550,6 +550,8 @@ void           gtk_widget_unmap               (GtkWidget           *widget);
 void      gtk_widget_realize             (GtkWidget           *widget);
 void      gtk_widget_unrealize           (GtkWidget           *widget);
 
+void       gtk_widget_draw                (GtkWidget           *widget,
+                                           cairo_t             *cr);
 /* Queuing draws */
 void      gtk_widget_queue_draw          (GtkWidget           *widget);
 void      gtk_widget_queue_draw_area     (GtkWidget           *widget,